package org.alwayssuper.protocol.commons.transform.realtimev2016.enums;

/**
 * 车辆状态枚举 (整车数据 0x01)
 * 基于 GB/T 32960.3-2016 标准
 * @author alwaysSuper
 */
public enum VehicleStatus {
    STARTED(0x01, "启动状态"),
    STOPPED(0x02, "熄火状态"),
    OTHER(0x03, "其他状态"),
    ABNORMAL(0xFE, "异常"),
    INVALID(0xFF, "无效");

    private final int code;
    private final String description;

    VehicleStatus(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static VehicleStatus fromCode(int code) {
        for (VehicleStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        return INVALID;
    }

    @Override
    public String toString() {
        return String.format("VehicleStatus{code=0x%02X, description='%s'}", code, description);
    }
}